FILE(GLOB FLTK_ALL_SRC "*.[fF][lL]")

SET(FLTK_CPP_SRC "")

FOREACH(FLTK_SRC ${FLTK_ALL_SRC})
    # generate fltk output source file name
    GET_FILENAME_COMPONENT(T_BASENAME ${FLTK_SRC} NAME_WE)
    SET(T_OUT_CPPNAME ${T_BASENAME}.cpp)
    SET(T_OUT_HPPNAME ${T_BASENAME}.hpp)

    SET(FLTK_CPP_SRC
        ${FLTK_CPP_SRC}
        ${CMAKE_CURRENT_BINARY_DIR}/${T_OUT_HPPNAME}
        ${CMAKE_CURRENT_BINARY_DIR}/${T_OUT_CPPNAME})

    ADD_CUSTOM_COMMAND(OUTPUT ${T_OUT_HPPNAME} ${T_OUT_CPPNAME}
        DEPENDS ${FLTK_SRC}
        COMMAND fluid -c -o ${T_OUT_CPPNAME} -h ${T_OUT_HPPNAME} ${FLTK_SRC}
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
        )
ENDFOREACH()

AUX_SOURCE_DIRECTORY(. SHADOWMAKER_SRC)
ADD_EXECUTABLE(herowil2png ${SHADOWMAKER_SRC} ${FLTK_CPP_SRC})
ADD_DEPENDENCIES(herowil2png mir2x_3rds)

TARGET_INCLUDE_DIRECTORIES(herowil2png PRIVATE ${MIR2X_COMMON_SOURCE_DIR})
TARGET_INCLUDE_DIRECTORIES(herowil2png PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
TARGET_INCLUDE_DIRECTORIES(herowil2png PRIVATE ${CMAKE_CURRENT_LIST_DIR})

TARGET_LINK_LIBRARIES(herowil2png ${FLTK_LIBRARIES}  )
TARGET_LINK_LIBRARIES(herowil2png ${OPENGL_LIBRARIES})
TARGET_LINK_LIBRARIES(herowil2png ${CMAKE_DL_LIBS}                 )
TARGET_LINK_LIBRARIES(herowil2png common             )
TARGET_LINK_LIBRARIES(herowil2png ${TINYXML2_LIBRARIES})
TARGET_LINK_LIBRARIES(herowil2png PNG::PNG                )
